#!/bin/sh
#
# Copyright (C) 2011-2012 OpenWrt.org
#

[ -e /etc/config/ubootenv ] && exit 0

touch /etc/config/ubootenv

. /lib/uboot-envtools.sh
. /lib/functions.sh

board=$(board_name)

case "$board" in
cmcc,rax3000m-emmc |\
cmcc,xr30-emmc |\
glinet,gl-mt6000 |\
jdcloud,re-cp-03)
	env_dev=$(find_mmc_part "u-boot-env")
	[ -n "$env_dev" ] && ubootenv_add_uci_config "$env_dev" "0" "0x80000"
	;;
*360,t7* |\
ruijie,rg-x30e* |\
*newland,nl-wr8103* |\
newland,nl-wr9103 |\
livinet,zr-3020*)
	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" "1"
	;;
h3c,nx30pro |\
*clt,r30b1* |\
ruijie,rg-x60-pro* |\
cmcc,xr30 |\
cmcc,rax3000m)
	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x80000" "0x20000" "4"
	;;
*honor,fur-602* |\
*imou,lc-hx3001*)
	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x80000" "0x80000" "1"
	;;
xiaomi,mi-router-ax3000t* |\
xiaomi,mi-router-wr30u* |\
xiaomi,redmi-router-ax6000*)
	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x10000" "0x20000" "1"
	;;
nradio,wt9103 |\
*konka,komi-a31*)
	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x80000" "1"
	;;
zyxel,ex5700)
	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x80000" "1"
	;;
esac

config_load ubootenv
config_foreach ubootenv_add_app_config ubootenv

exit 0
